﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：RedisKeys.cs
// 功能描述：TongTongMall.MallWeb.Core
// 
// Create User：jym 2017/02/09
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TongTongMall.MallWeb.Core.Identitys
{
    public class RedisKeys
    {
        public static RedisKeys Instance { get; private set; }

        static RedisKeys()
        {
            Instance = new RedisKeys();
        }

        #region 公共缓存

        /// <summary>
        /// 所有租户数据在redis内的key值
        /// common:CommercialTenant:getTenantInfo:{tenantName}
        /// </summary>
        public Tuple<string, RedisKeyConfig> TenantInfo_Key = new Tuple<string, RedisKeyConfig>("common:CommercialTenant:getTenantInfo", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(30)
        });


        /// <summary>
        /// 国家列表在redis内的key值
        /// </summary>
        public Tuple<string, RedisKeyConfig> CountryByAdsLevel20List_Key = new Tuple<string, RedisKeyConfig>("common:DicAddress:getCountryByAdsLevel20", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(30)
        });


        /// <summary>
        /// 省市县信息列表在redis内的key值
        /// </summary>
        public Tuple<string, RedisKeyConfig> AddresssList_Key = new Tuple<string, RedisKeyConfig>("common:DicAddress:getAllAddress", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(30)
        });
        /// <summary>
        /// 待推送消息之订单支付在redis内的key值
        /// </summary>
        public Tuple<string, RedisKeyConfig> StayPushMessage_OrderPay_Key = new Tuple<string, RedisKeyConfig>("common:PushMessage:StayPush:OrderPayVer2", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.MaxValue
        });
        #endregion

        #region 租户内缓存

        /// <summary>
        /// 商品分类在redis内的key值
        /// {tenantName}:product_category:getCategoryList
        /// </summary>
        public Tuple<string, RedisKeyConfig> ProductCategory_Key = new Tuple<string, RedisKeyConfig>("product_category:getCategoryList", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(1)
        });

        /// <summary>
        /// 商城配置在redis内的缓存
        /// {tenantName}:configMallInfo:getconfigMallInfo
        /// </summary>
        public Tuple<string, RedisKeyConfig> MallWebConfig_Key = new Tuple<string, RedisKeyConfig>("configMallInfo:getconfigMallInfo", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(10)
        });

        /// <summary>
        /// 品牌列表在redis内的key值
        /// {tenantName}:productBrand:getBrandList
        /// </summary>
        public Tuple<string, RedisKeyConfig> BrandList_Key = new Tuple<string, RedisKeyConfig>("productBrand:getBrandList", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(1)
        });

        /// <summary>
        /// 帮助页文章与分类在redis内的key值
        /// {tenantName}:dicCategory:getArticleCategory
        /// </summary>
        public Tuple<string, RedisKeyConfig> ArticleCategory_Key = new Tuple<string, RedisKeyConfig>("dicCategory:getArticleCategory", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(10)
        });


        /// <summary>
        /// APP版本信息在redis内的key值
        /// {tenantName}:applicationVersionInfo:getAppVersion
        /// </summary>
        public Tuple<string, RedisKeyConfig> AppVersion_Key = new Tuple<string, RedisKeyConfig>("applicationVersionInfo:getAppVersion", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(1)
        });

        /// <summary>
        /// 字典信息在redis内的key值
        /// {tenantName}:netdataDictionary:getDictionary
        /// </summary>
        public Tuple<string, RedisKeyConfig> NetDataDictionary_Key = new Tuple<string, RedisKeyConfig>("netdataDictionary:getDictionary", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(10)
        });

        /// <summary>
        /// 积分全局配置在redis内的key值
        /// {tenantName}:configScore:getConfigScore
        /// </summary>
        public Tuple<string, RedisKeyConfig> ConfigScore_Key = new Tuple<string, RedisKeyConfig>("configScore:getConfigScore", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(10)
        });


        /// <summary>
        /// 海报信息图片配置在redis内的key值
        /// {tenantName}:pageAreaContent:getPoster
        /// </summary>
        public Tuple<string, RedisKeyConfig> Poster_Key = new Tuple<string, RedisKeyConfig>("pageAreaContent:getPoster", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(5)
        });

        /// <summary>
        /// 租户内订单序列
        /// {tenantName}:sequence:orderSequence
        /// </summary>
        public Tuple<string, RedisKeyConfig> OrderSequence_Key = new Tuple<string, RedisKeyConfig>("sequence:orderSequence", new RedisKeyConfig
        {
            ExpireTime = DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(1) - DateTime.Now
        });

        /// <summary>
        /// 短信验证码序列
        /// {tenantName}:sequence:{account}:{usetype}
        /// </summary>
        public Tuple<string, RedisKeyConfig> VCode_Key = new Tuple<string, RedisKeyConfig>("sequence", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromMinutes(10)
        });
        #endregion

        #region 租户内用户缓存

        /// <summary>
        /// 租户名称:users:用户编号:授权平台
        /// {tenantName}:users:{userNum}:{tk}
        /// </summary>
        public string UserAuthorizationAfterRedisKey(string tenantName, string userNum, string tk)
        {
            return string.Format("{0}:users:{1}:{2}", tenantName, userNum, tk);
        }

        /// <summary>
        /// 找回密码在redis内的key值
        /// {tenantName}:{username}:temp:user_findpwd:getValidTempCode
        /// </summary>
        public Tuple<string, RedisKeyConfig> User_FindPwd_Key = new Tuple<string, RedisKeyConfig>("temp:user_findpwd:getValidTempCode", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromMinutes(5)
        });

        /// <summary>
        /// 用户设置邮箱临时数据在redis内的缓存
        /// {tenantName}:{userNum}:temp:user_setEmail:getVaildTempCode
        /// </summary>
        public Tuple<string, RedisKeyConfig> User_SetEmail_Key = new Tuple<string, RedisKeyConfig>("temp:user_setEmail:getVaildTempCode", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromMinutes(10)
        });

        /// <summary>
        /// 用户购物车的缓存数据
        /// {tenantId}:{sessionkey}:user_shopping:getUserShoppingCart
        /// </summary>
        public Tuple<string, RedisKeyConfig> User_ShoppingCart_Key = new Tuple<string, RedisKeyConfig>("user_shopping:getUserShoppingCart", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(30)
        });

        /// <summary>
        /// 用户确认订单临时数据在redis内的缓存
        /// </summary>
        public Tuple<string, RedisKeyConfig> User_ConfirmOrder_Key = new Tuple<string, RedisKeyConfig>("temp:user_confirmOrder:getOrderInfo", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromMinutes(10)
        });

        /// <summary>
        /// 获取专题信息临时数据在redis内的缓存
        /// </summary>
        public Tuple<string, RedisKeyConfig> Topics_info_key = new Tuple<string, RedisKeyConfig>("temp:topics_info:gettopicsInfo", new RedisKeyConfig
        {
            ExpireTime = TimeSpan.FromDays(1)
        });

        #endregion

    }
}
